package com.baidu.www2;

class Animal{
    public String name;
    public int age;
    protected int count;
    public  Animal(String name,int age){
        this.name = name;
        this.age = age;
        eat();
    }
    public  void eat(){
        System.out.println(name + " eating some food");
    }
}
class Dog extends Animal{
    public Dog(String name,int age){
        super(name, age);// 调用父类 带有两个参数的构造方法。
        // 而且super() 和 this() 一样，都是调用构造方法，位置只能放在第一行
    }
    @Override// 检查是否 是重写
    public void eat(){
        System.out.println(name + "狼吞虎咽");
    }
    public void func(int a){
        System.out.println("int");
    }
    public void func(int a,int b){
        System.out.println("int,int");
    }
    public void func(int a,int b,int c){
        System.out.println("int,int,int");
    }
}

class Bird extends Animal{
    public String wing;
    public String name = "hehe";
    public Bird(String name,int age,String wing){
        super(name,age);
        this.wing = wing;
    }
    public void fly(){

        System.out.println(super.age+"岁的"+super.name + "展开"+ this.wing );
        System.out.println(super.age+"岁的"+name + "展开"+ this.wing );
    }
}
public class Test {
    public static void main(String[] args) {
        Animal animal = new Dog("hello",1);
    }


//    public static void main(String[] args) {
//        Animal animal = new Bird("haha",19,"翅膀");
//        if(animal instanceof Bird){
//            Bird bird = (Bird) animal;
//            bird.fly();
//        }
//
//    }
//    public static void main(String[] args) {
//        Dog dog = new Dog("二哈",19);
//        dog.func(1);
//    }


    public static void func(Animal ani) {

    }
    public static Animal func2(){
        Dog dog = new Dog("二哈",1);
        return dog;
    }
    public static void main3(String[] args) {
        Dog dog = new Dog("二哈",1);
//        Animal animal = dog;
//        Animal animal = new Dog("二哈",1);
//        // 父类引用  引用 子类对象
        func(dog);
    }


    public static void main2(String[] args) {
        Test2 test2 = new Test2();
        System.out.println(test2.val2);
    }
}
